package com.captjack.bigdata.hadoop.hbase.trace.impl;

import com.captjack.bigdata.hadoop.hbase.base.AbstractHadoopDatabaseDao;
import com.captjack.bigdata.hadoop.hbase.trace.HBaseTraceDao;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.util.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Capt Jack
 * @date 2018/3/6
 */
@Repository
public class HBaseTraceDaoImpl extends AbstractHadoopDatabaseDao implements HBaseTraceDao {

    /**
     * 日志
     */
    private static final Logger logger = LoggerFactory.getLogger(HBaseTraceDaoImpl.class);

    @Override
    public void hello() {
        try {
            Scan scan = new Scan();
            List<Object> list = getHbaseTemplate().find(HADOOP_DATABASE_NAME, scan, (result, i) -> Bytes.toString(result.getValue(Bytes.toBytes("Cf"), Bytes.toBytes("info"))));
            for (Object object : list) {
                System.out.println(object.toString());
            }
            System.out.println(getHbaseTemplate().getCharset().displayName());
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("", e);
        }
    }

}
